package cn.outsourcing.supermarket.converter;

import cn.outsourcing.supermarket.converter.transform.BooleanToIntegerTransform;
import cn.outsourcing.supermarket.po.HiolabsOrder;
import cn.outsourcing.supermarket.vo.OrderInfoVO;
import cn.outsourcing.supermarket.vo.OrderVO;
import cn.outsourcing.supermarket.vo.backstage.BackstageOrdersInfoVO;
import cn.outsourcing.supermarket.vo.hiolabs.HiolabsOrderVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 产品转换器
 *
 * @author gzkemays
 * @since 2021/10/22 16:00
 */
@Mapper(uses = {BooleanToIntegerTransform.class})
public interface HiolabsOrderConverter {
  HiolabsOrderConverter INSTANCE = Mappers.getMapper(HiolabsOrderConverter.class);
  /**
   * 转化为缺省值对象
   *
   * @param data 原 po 对象
   * @return 自身值对象
   */
  OrderVO convertToDefaultVo(HiolabsOrder data);
  /**
   * 转化为订单扩展信息列表值对象
   *
   * @param list 原 po 列表对象
   * @return 自身值对象
   */
  List<OrderVO> convertToVoList(List<HiolabsOrder> list);

  /**
   * 转化为订单扩展信息
   *
   * @param data 原 po 对象
   * @return 自身值对象
   */
  @Mapping(
      target = "payTime",
      expression =
          "java(cn.outsourcing.supermarket.common.utils.DataUtils.getTimestampAllData(data.getPayTime()))")
  OrderInfoVO convertToInfoVo(HiolabsOrder data);

  /**
   * 转化为后台订单值对象
   *
   * @param order 原 po 对象
   * @return 后台订单值对象
   */
  @Mappings({
    @Mapping(
        target = "addTime",
        expression =
            "java(cn.outsourcing.supermarket.common.utils.DataUtils.getTimestampAllData(order.getAddTime()))"),
    @Mapping(
        target = "payTime",
        expression =
            "java(cn.outsourcing.supermarket.common.utils.DataUtils.getTimestampAllData(order.getPayTime()))"),
    @Mapping(
        target = "shippingTime",
        expression =
            "java(cn.outsourcing.supermarket.common.utils.DataUtils.getTimestampAllData(order.getShippingTime()))"),
    @Mapping(
        target = "confirmTime",
        expression =
            "java(cn.outsourcing.supermarket.common.utils.DataUtils.getTimestampAllData(order.getConfirmTime()))"),
    @Mapping(
        target = "dealdoneTime",
        expression =
            "java(cn.outsourcing.supermarket.common.utils.DataUtils.getTimestampAllData(order.getDealdoneTime()))")
  })
  BackstageOrdersInfoVO convertToBackstageVo(HiolabsOrder order);

  List<BackstageOrdersInfoVO> convertToBackstageVoList(List<HiolabsOrder> order);
  /**
   * 转化为自身值对象
   *
   * @param data 原 po 对象
   * @return 自身值对象
   */
  HiolabsOrderVO convertToVo(HiolabsOrder data);
}
